package com.shujia.mllib

import java.io.StringReader

import org.wltea.analyzer.core.{IKSegmenter, Lexeme}

import scala.collection.mutable.ListBuffer

object Demo8IK {
  def main(args: Array[String]): Unit = {

    val text = "数加学院牛逼"


    val words: List[String] = fit(text)

    println(words)
  }


  def fit(text: String): List[String] = {

    val listBuffer = new ListBuffer[String]

    val sr = new StringReader(text)
    val ik = new IKSegmenter(sr, true)
    //取第一个
    var word: Lexeme = ik.next()

    while (word != null) {

      listBuffer += word.getLexemeText

      //取下一个
      word = ik.next()
    }

    listBuffer.toList
  }

}
